package com.lagou.service.impl;

import com.lagou.common.ServerResponse;
import com.lagou.mapper.EduMapper;
import com.lagou.service.IEduService;
import com.lagou.vo.ConverterVo;
import com.lagou.vo.EduVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
public class EduServiceImpl implements IEduService {

    @Autowired
    private EduMapper eduMapper;

    @Override
    public ServerResponse<Map<String, Object>> findEduNum() {
        Map<String,Object> eduMap = new HashMap<>();
        List<String> names = new ArrayList<>();
        List<Integer> countNum = new ArrayList<>();
        List<ConverterVo> eduNum = eduMapper.findEduNum();
        for (ConverterVo converterVo : eduNum) {
            names.add(converterVo.getName());
            countNum.add(converterVo.getValue());
        }
        eduMap.put("names",names);
        eduMap.put("countNum",countNum);
        eduMap.put("eduData",eduNum);
        return ServerResponse.createBySuccessData(eduMap);

    }
}
